The
Task Scheduler enables you to automate many different tasks on your
server. You might be familiar with the Task Scheduler from previous
Windows server operating systems. However, the Task Scheduler in
Windows Server 2008 has much more functionality than those earlier
versions.
You can get
to the Task Scheduler in more than one way, and one of the easiest is
to open Server Manager. From Server Manager, you navigate to
Configuration and then Task Scheduler. When you highlight the Task
Scheduler, you see the following:
An overview of Task Scheduler: You see information on what you can do with Task Scheduler and some instructions on how to use it.
Task status:
Here you can see whether your scheduled tasks are running successfully.
On the top right you can select how far back you want to check, with
options of last 1 hour, last 24 hours, last 7 days, and last 30 days.
Then, by expanding the tasks listed in the lower portion, you can
confirm whether a scheduled task completed successfully.
Active tasks: All tasks that are active (that is, scheduled tasks that are scheduled to be run and have not expired) are shown in this area.
If you select Task Scheduler, Task Scheduler Library, Microsoft, Windows, you see some preconfigured tasks, as shown in Figure 1. Also notice that you can organize your scheduled tasks in folders.
Figure 1. Task Scheduler overview and preconfigured tasks.
A
big difference between older versions of Task Scheduler and the current
one is the number of triggers available to kick off a scheduled task. A
trigger is an event that causes a scheduled task to start. In previous
versions of Windows server operating systems, you could only have a
task scheduled to run at a specified time and reoccur at the same time,
if needed. The time of day would be the trigger for the scheduled task.
With Windows Server 2008, you can use the following triggers:
On a schedule
At logon
At startup
On idle
On an event
At task creation/modification
On connection to a user session
On disconnect from a user session
On workstation lock
On workstation unlock
We have certainly come a long way from the AT
command prompt tool in the NT 4.0 days. The new Task Scheduler gives
you a wide variety of options for scheduling tasks. We will take a look
at the steps involved in creating a scheduled task that brings up a
message when the server is unlocked. As you go through the steps,
you’ll learn about some of the other new features of Task Scheduler.
Follow these steps:
1. | Open Server Manager (or Computer Manager).
|
2. | Navigate to Task Scheduler. In Server Manager, Task Scheduler is found under Configuration.
|
3. | In the Actions pane (right side) are two options to create a task:
- Create a Basic Task: This takes you through a wizard to create a scheduled task.
- Create Task: This option allows you to create a scheduled task manually.
Click Create Task to open the Create Task dialog box (see Figure 2).
Figure 2. The Create Task dialog box.
|
4. | In the General tab, enter the following:
The task name A description of the task The account the task will run under Whether the task should run only when a user is logged on or if it can run whether a user is logged on or not The privilege level Whether you want the task to be hidden
|
5. | Click the Triggers tab and then click New. The New Trigger dialog box appears (see Figure 3).
Click on the Begin the Task drop-down box to display all the triggers
available. The options in this dialog box change, depending on which
trigger is selected. Select On Workstation Unlock.
Figure 3. Selecting a trigger for a scheduled task.
|
6. | With this trigger selected, do any of the following, as needed:
Select any user or a specified user Delay the task Repeat the task Stop the task if it runs longer than a specified time Activate and expire the task on set dates Enable the task
Notice that you can have more than one trigger for each of your scheduled tasks.
Note
Many
of the selections in the New Trigger dialog box are the same for all
the triggers, but some differ. Select each one to see the differences.
|
7. | Click the Actions tab and then New. The New Action dialog box appears (see Figure 4). The action is the task that needs to be run. There are three actions to select from:
Start a Program Send an E-mail Display a Message
Figure 4. Selecting an action.
Select Display a Message. (Note that the dialog box options vary, depending on your selection.)
|
8. | Give
the message a title and add what you want to say in the message. For
example, you might want the message to say “Please do not log off user”
because when servers run applications in a console, it may be necessary
for a user to be logged on to have the application run.
|
9. | Click the Conditions tab and set the following:
- Start only if the computer is idle and specify how long to wait for idle. Also stop if the computer ceases to be idle.
- Start only if connected to AC power and stop if switched to battery power.
- Wake the computer to run the task.
- Run only if a specified network connection is available.
|
10. | Click the Settings tab, and you see the following options for your scheduled task:
- Allow task to be run on demand
- Run task ASAP after the scheduled time is missed
- Restart the task if it fails on a certain interval and up to a specified number of times.
- Stop the task if it runs too long
- Force the task to stop if it does not end when requested
- Delete the task if it is not scheduled to run again after a specified amount of time
You can also specify how to manage a new instance of the task.
|
When
you click OK, you have successfully configured a scheduled task. You
can test your task by locking the server and then unlocking it to see
if you get the message.
In
this section, you created a simple scheduled task to show the
functionality of the improved Task Scheduler. You can clearly see that
this tool can be leveraged in many ways to successfully manage your
Windows Server 2008 infrastructure.